

import 'package:json_annotation/json_annotation.dart';

part 'config_model.g.dart';

@JsonSerializable()
class TaskConfigModel {
  @JsonKey(name: 'indexComponents')
  final List<IndexComponent> indexComponents;

  @JsonKey(name: 'categories')
  final List<Category> categories;

  @JsonKey(name: 'sortValueOptions')
  final List<SortValueOption> sortValueOptions;

  TaskConfigModel({
    required this.indexComponents,
    required this.categories,
    required this.sortValueOptions,
  });

  factory TaskConfigModel.fromJson(Map<String, dynamic> json) =>
      _$TaskConfigModelFromJson(json);

  Map<String, dynamic> toJson() => _$TaskConfigModelToJson(this);
}

@JsonSerializable()
class IndexComponent {
  final String componentName;
  final String displayType;
  final List<ComponentDto> componentDtos;

  IndexComponent({
    required this.componentName,
    required this.displayType,
    required this.componentDtos,
  });

  factory IndexComponent.fromJson(Map<String, dynamic> json) =>
      _$IndexComponentFromJson(json);

  Map<String, dynamic> toJson() => _$IndexComponentToJson(this);
}

@JsonSerializable()
class ComponentDto {
  final String title;
  final String subTitle;
  final String description;
  final String iconUrl;
  final String type;
  @JsonKey(name: 'openUrl')
  final String openUrl;
  final String taskType;
  final bool needCity;
  final bool onlyDisplayInVerify;

  ComponentDto({
    required this.title,
    required this.subTitle,
    required this.description,
    required this.iconUrl,
    required this.type,
    required this.openUrl,
    required this.taskType,
    required this.needCity,
    required this.onlyDisplayInVerify,
  });

  factory ComponentDto.fromJson(Map<String, dynamic> json) =>
      _$ComponentDtoFromJson(json);

  Map<String, dynamic> toJson() => _$ComponentDtoToJson(this);
}

@JsonSerializable()
class Category {
  @JsonKey(name: 'categoryIcon')
  final String categoryIcon;

  @JsonKey(name: 'categoryDescription')
  final String categoryDescription;

  @JsonKey(name: 'serviceFeePercent')
  final double serviceFeePercent;

  @JsonKey(name: 'categoryName')
  final String categoryName;

  @JsonKey(name: 'priorityDescription')
  final String priorityDescription;

  @JsonKey(name: 'incomeDescription')
  final String incomeDescription;

  Category({
    required this.categoryIcon,
    required this.categoryDescription,
    required this.serviceFeePercent,
    required this.categoryName,
    required this.priorityDescription,
    required this.incomeDescription,
  });

  factory Category.fromJson(Map<String, dynamic> json) =>
      _$CategoryFromJson(json);

  Map<String, dynamic> toJson() => _$CategoryToJson(this);
}

@JsonSerializable()
class SortValueOption {
  @JsonKey(name: 'optionDisplay')
  final String optionDisplay;

  @JsonKey(name: 'optionValue')
  final String optionValue;

  SortValueOption({
    required this.optionDisplay,
    required this.optionValue,
  });

  factory SortValueOption.fromJson(Map<String, dynamic> json) =>
      _$SortValueOptionFromJson(json);

  Map<String, dynamic> toJson() => _$SortValueOptionToJson(this);
}